package com.appkubes.mall.restful.application.user.hierarchy.dao;

import com.appkubes.mall.core.dao.BaseMallUserHierarchyDao;
import com.appkubes.mall.core.entity.MallUserHierarchy;
import com.appkubes.mall.restful.application.user.hierarchy.entity.dto.UserHierarchyDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @Author: Rongjie
 * @Date: 2020/2/29
 * @Description:
 */
@Repository
public interface UserHierarchyDao extends BaseMallUserHierarchyDao {

    //获取用户的推广下级用户信息
    @Select({"select muh.promoter_key, mu.tel, mu.name, mu.img, mu.create_time, mu.nick_name, mu.id_card, dit.credit_status ",
            "  from mall_user_hierarchy muh  join mall_user mu on muh.user_key = mu.user_key" +
            " left join fintech_credit dit on dit.user_key = muh.user_key",
            " where muh.parent_user_key = #{userKey} ORDER BY mu.create_time DESC   "
    })
    IPage<UserHierarchyDTO> getListByParentKey(IPage<MallUserHierarchy> page, @Param("userKey") String userKey);


    //获取用户的推广下级用户信息
    @Select({"select muh.promoter_key, mu.tel, mu.name, mu.img, mu.create_time, mu.nick_name, mu.id_card ",
            "  from mall_user_hierarchy muh  join mall_user mu on muh.user_key = mu.user_key",
            " where muh.parent_user_key2 = #{userKey}"
    })
    IPage<UserHierarchyDTO> getListByParentKey2(IPage<MallUserHierarchy> page, @Param("userKey") String userKey);
}
